﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Core.Infrastructure.Controls;
using CThru.Silverlight;
using System.Windows.Media.Animation;
using TypeMock.ArrangeActAssert;

namespace Core.Infrastructure.Test
{
    [TestFixture]
    public class BusyAnimationTests
    {
        [Test, SilverlightUnitTest]
        public void OnApplyTemplate_AnimatioNotNull_AnimationBegin()
        {
            BusyAnimation busyAnimation = new BusyAnimation();
            Storyboard animation = Isolate.Fake.Instance<Storyboard>();
            SilverUnit.SetTemplateChild(busyAnimation, "Animation", animation);

            busyAnimation.OnApplyTemplate();

            Isolate.Verify.WasCalledWithAnyArguments(() => animation.Begin());
        }

        [Test, SilverlightUnitTest]
        public void OnApplyTemplate_AnimatioNull_ExceptionNotThrown()
        {
            BusyAnimation busyAnimation = new BusyAnimation();
            SilverUnit.SetTemplateChild(busyAnimation, "Animation", null);

            Assert.DoesNotThrow(() => busyAnimation.OnApplyTemplate());
        }
    }
}
